﻿using System.Data.Entity.ModelConfiguration;
using ZY.EntityFrameWork.Core.Model.Entity;
using ZY.EntityFrameWork.Core.Model.Entity.Authority;

namespace ZY.EntityFrameWork.Core.Mapping.SQLServer
{
    public class RoleMap: EntityTypeConfiguration<Role>
    {
        public RoleMap()
        {
            ToTable("RoleInfo").HasKey(q => q.Id);
            HasMany(q => q.Users).WithRequired(q => q.UserRole).HasForeignKey(q=>q.RoleId);
            HasMany(q => q.RoleModules).WithRequired(q => q.Role).HasForeignKey(q=>q.RoleId);
        }
    }
}
